<!--
- File:    退货详情页.
-->
<template>
  <div>
    <div class="p20 bg_fff apply_box" v-show="refundInfo.seller_state == $dictionary.refundStatus.resolve">
      <h3>请退货给商家</h3>
      <div class="apply_text">退货地址：{{expressInfo.address.address}}</div>
      <div class="apply_sel3 mt20">
        <button @click="addExpress" v-show="refundInfo.express_id == 0">填写退货物流</button>
        <button @click="gotoOrderExpress(refundInfo.order_id)" v-show="refundInfo.express_id != 0">查看退货物流</button>
      </div>
    </div>
    <div class="apply_li mt20">
      <ul>
        <li>退货状态：<span class="cr_41a536">{{refundInfo.seller_state | refundStatusName}}</span></li>
        <li>退货类型：退款退货</li>
        <li>退货编号： {{refundInfo.refund_sn}}</li>
        <li>退货原因： {{refundInfo.reason_info}}</li>
        <li>退还金额： ¥{{refundInfo.pay_refund_amount}}</li>
        <li>退还积分： {{refundInfo.integral_amount}}积分</li>
        <li>退货数量： {{refundInfo.goods_num}}</li>
        <li>退货说明： {{refundInfo.buyer_message}}</li>
        <li>商家备注： {{refundInfo.seller_message}}</li>
      </ul>
    </div>
    <div class="apply_sel2 p20">
      <button @click="goBack">返回上一页</button>
    </div>
  </div>
</template>

<script>
  import * as dictionary from '../../../dictionary'
  export default{
    data() {
      return {
        refundId: this.$route.params.id,
        refundInfo: {},
        expressInfo: {address: {}, express: null, info: {}}
      }
    },
    components: {},
    created() {
      this.getRefundInfo(this.refundId)
      this.getExpressInfo(this.refundId)
    },
    filters: {
      refundStatusName: function (value) {
        let name = ''
        switch (value) {
          case dictionary.refundStatus.waiting:
            name = '等待审核'
            break
          case dictionary.refundStatus.resolve:
            name = '卖家已同意'
            break
          case dictionary.refundStatus.reject:
            name = '卖家已拒绝'
            break
        }
        return name
      }
    },
    methods: {
      gotoOrderExpress(id) {
        this.$router.push({name: 'order-express', params: {id: id}})
      },
      goBack() {
        this.$router.go(-1)
      },
      getRefundInfo(id) {
        this.$request.getRefundInfo(id).then(data => {
          this.refundInfo = data
        })
      },
      addExpress() {
        this.$router.push({name: 'refund-goods-express', query: {refundId: this.refundInfo.refund_id}})
      },
      getExpressInfo(id) {
        this.$request.getRefundExpress(id).then(data => {
          this.expressInfo = data
        })
      }
    }
  }
</script>

<style>

</style>